package com.JZ.QM.controller;

import com.JZ.QM.common.utils.CommonResult;
import com.JZ.QM.feign.AccountFeignService;
import com.JZ.QM.service.ProductEarningRecordService;
import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.dynamic.scaffold.MethodGraph;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;

/**
 * @author: cyc
 * @email cyc@gmail.com
 * @date: 2020/7/8 11:38
 */
@RefreshScope
@RestController
@Slf4j
@RequestMapping("/productEarningRecord")
public class ProductEarningRecordControlller {

    @Resource
    ProductEarningRecordService productEarningRecordService;
    @Resource
    AccountFeignService accountFeignService;

    /**
     * 进行组合中产品成分可视化
     * @param accountId
     * @return
     */
    @RequestMapping("/showProductEarningRecordForChart")
    public CommonResult showProductEarningRecordForChart(Long accountId){
        //产品的日收益可视化信息
        ArrayList<HashMap> productDailyEarning=new ArrayList<>();

        //获取产品收益记录
        productDailyEarning=productEarningRecordService.showProductEarningRecordForChart(accountId);
        if(productDailyEarning.isEmpty()){
            return CommonResult.success().put("productEarnings",new ArrayList().toArray());
        } else {
            return CommonResult.success().put("productEarnings",productDailyEarning.toArray());
        }

    }



}
